package com.ztgf.commodity.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ztgf.commodity.common.config.YmlConfig;
import com.ztgf.commodity.mapper.CommodityBrowseRecordingMapper;
import com.ztgf.commodity.models.dto.CommodityBrowseRecordingDTO;
import com.ztgf.commodity.models.dto.CommodityInfoDTO;
import com.ztgf.commodity.models.service.ICommodityBrowseRecordingService;
import com.ztgf.commodity.models.service.ICommodityInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;

/*
 * @author: chenyu.wang
 * @date: 2020-09-03
 * @description:
 */
@Slf4j
@DubboService
public class CommodityBrowseRecordingServiceImpl extends ServiceImpl<CommodityBrowseRecordingMapper, CommodityBrowseRecordingDTO> implements ICommodityBrowseRecordingService {

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public void add(CommodityBrowseRecordingDTO dto) {
        CommodityBrowseRecordingDTO saveDTO = new CommodityBrowseRecordingDTO();
        saveDTO.setGoodsId(dto.getGoodsId());
        saveDTO.setIp(dto.getIp());
        saveDTO.setUri(dto.getUri());
        saveDTO.setActionName(dto.getActionName());
        saveDTO.setParams(dto.getParams());
        saveDTO.setId(ymlConfig.getPkId());
        boolean insert = this.insert(dto);
        if (insert) {
            log.info("保存商品浏览记录成功!");
        } else {
            log.info("保存商品浏览记录失败!");
        }
    }


}
